New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
@babel/eslint-parser: fix ImportExpression node to match ESTree spec #10828
@babel/eslint-parser: fix ImportExpression node to match ESTree spec #10828
Conversation
...perimental/class-properties/arguments-in-nested-class-decorator-call-expression/options.json
Outdated
Show resolved
Hide resolved
a9dca47
to
e51ed79
Compare
e8fbad0
to
2b0b1ee
Compare
@@ -518,5 +518,11 @@ describe("babylon-to-espree", () => { | |||
} | |||
`); | |||
}); | |||
|
|||
it("Dynamic Import", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to be able to test this across the parser and the estree plugin :)
Wrestling with some Flow types right now (I haven't used Flow in years 馃槵), but will hopefully have that fixed up soon. |
2bcbc0c
to
c25b1e7
Compare
Still struggling with the flow types on this one (trying to avoid using |
packages/babel-parser/test/fixtures/estree/dynamic-import/basic/output.json
Outdated
Show resolved
Hide resolved
The problem with flow is that a function returns |
ee14f2d
to
93a3451
Compare
|
||
// ImportExpressions do not have an arguments array. | ||
toReferencedListDeep( | ||
exprList: $ReadOnlyArray<?N.Expression> = [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was crashing because it's given the CallExpression
's arguments
array, which is undefined
for ImportExpression
s (deleted above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about doing this? We avoid using the empty array and iterating it:
toReferencedListDeep(exprList: ?$ReadOnlyArray<?N.Expression>) {
if (exprList) return super.toReferencedListDeep(exprList);
}
If flow complains that it can't return undefined, we can just change the original toReferencedListDeep
signature to return void
, since it's return value is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that sounds good to me. Updated!
575753b
to
4a76f37
Compare
4a76f37
to
2e77d76
Compare
@babel/parser
currently parses dynamic imports (import('a')
) asCallExpression
s (code here). The ESTree spec differs from this and gives it its own type calledImportExpression
.